package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.DecreaseBean;
import com.lwj.liwanjia.impl.DecreaseView;
import com.lwj.liwanjia.model.DecreaseModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/2.
 */

public class DecreasePresenter {
    private DecreaseModel decreaseModel;
    private DecreaseView decreaseView;

    public DecreasePresenter(DecreaseView decreaseView) {
        this.decreaseView = decreaseView;
        decreaseModel = new DecreaseModel();
    }

    public void decreaseGwc(String token, String commendityCode, String commendityType, double price) {
        if (decreaseView != null) {
            decreaseModel.decreaseGwc(token, commendityCode, commendityType, price, new Subscriber<DecreaseBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    decreaseView.showError((Exception) e);
                }

                @Override
                public void onNext(DecreaseBean decreaseBean) {
                    decreaseView.decreaseGwc(decreaseBean);
                }
            });
        }
    }
}
